package vertx;

import org.vertx.java.core.AsyncResult;
import org.vertx.java.core.AsyncResultHandler;
import org.vertx.java.core.Future;
import org.vertx.java.platform.Verticle;

public class StartApp extends Verticle {

	@Override
	public void start(final Future<Void> startedResult) {
		super.start(startedResult);
		// this Verticle initialize the application

		// questo modulo fatto da terze parti permette la gestione delle chiamate a pagine statiche
		//container.deployModule("io.vertx~mod-web-server~2.0.0-final");
		
		
		container.deployVerticle("vertx.BridgeServerHttp", new AsyncResultHandler<String>() {
			@Override
			public void handle(AsyncResult<String> result) {
				if (result.succeeded()) {
			        startedResult.setResult(null);
			      } else {
			    	container.logger().error(result.cause());
			        startedResult.setFailure(result.cause());
			      }				
			}
		});
		container.deployVerticle("vertx/WebClient.js");
	}
	
}
